package com.kust.smarthome.web.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kust.smarthome.web.mapper.HygrothermographMapper;
import com.kust.smarthome.web.model.Hygrothermograph;
import com.kust.smarthome.web.service.IHygrothermographService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HygrothermographServiceImpl extends ServiceImpl<HygrothermographMapper, Hygrothermograph> implements IHygrothermographService {

    @Autowired
    private HygrothermographMapper hygrothermographMapper;

    @Override
    public List<Hygrothermograph> getByUserId(Integer userId) {
        QueryWrapper<Hygrothermograph> query = new QueryWrapper<>();
        query.eq("user_id",userId);

        return hygrothermographMapper.selectList(query);
    }

    @Override
    public int insert(Hygrothermograph hygrothermograph) {
        hygrothermographMapper.insert(hygrothermograph);
        return hygrothermograph.getId();
    }
}
